﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using WebChatApi.Common.Interface;

namespace WebChatApi.Common
{
    /// <summary>
    /// Generic class for base service request
    /// </summary>
    [DataContract]
    public class BaseServiceRequest<T> : IServiceRequest, IIdentifiable
    {
        #region Properties

        /// <summary>
        /// Gets the key.
        /// </summary>
        /// <value>
        /// The key.
        /// </value>
        [DataMember]
        public Guid Key
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the session info.
        /// </summary>
        /// <value>
        /// The session info.
        /// </value>
        [DataMember]
        public SessionInfo SessionInfo
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the agent.
        /// </summary>
        /// <value>
        /// The agent.
        /// </value>
        [DataMember]
        public string Agent
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the refer.
        /// </summary>
        /// <value>
        /// The refer.
        /// </value>
        [DataMember]
        public string Refer
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the request detail.
        /// </summary>
        /// <value>
        /// The request detail.
        /// </value>
        [DataMember]
        public T RequestDetail
        {
            get;
            set;
        }

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="BaseServiceRequest{T}"/> class.
        /// </summary>
        public BaseServiceRequest()
        {
            this.Key = Guid.NewGuid();
        }

        #endregion

        /// <summary>
        /// Creates the web action track.
        /// </summary>
        /// <returns></returns>
        public WebActionTrack CreateWebActionTrack()
        {
            WebActionTrack track = new WebActionTrack();

            track.Agent = this.Agent;
            track.Refer = this.Refer;

            return track;
        }
    }
}
